<?php

namespace app\controller;

use app\BaseController;
use app\service\WarehouseService;
use app\service\WmsWarehouseAttrService;
use think\facade\Request;

/**
 * 仓库属性
 */
class WmsWarehouseAttr extends BaseController
{
    /**
     * @desc 仓库类型 业务类型
     * @return void
     */
    public function info()
    {
        $info = WarehouseService::info();
        returnSuccess(200, '获取成功', $info);
    }

    //属性列表
    public function lists()
    {
        $uid = Request::param('uid/d', 0);
        $param['page'] = Request::param('page/d', 0);
        $param['limit'] = Request::param('limit/d', 10);
        $logParam['uid'] = $uid;
        $param['partner_id'] = get_partner_id($uid);
        $logParam['ip'] = Request::ip();
        $data = WmsWarehouseAttrService::lists($param);
        if ($data) {
            returnSuccess(200, '获取成功', $data);
        } else {
            returnFail(21101, '获取失败');
        }
    }

    //新增属性
    public function add()
    {
        $uid = Request::param('uid/d', 0);
        $logParam['uid'] = $uid;
        $param['partner_id'] = get_partner_id($uid);
        $param['name'] = Request::param('name/s', '');
        $logParam['ip'] = Request::ip();
        $data = WmsWarehouseAttrService::add($param, $logParam);
        if ($data == 10000) {
            returnSuccess(200, '添加成功');
        } else {
            returnFail(21101, '添加失败');
        }
    }

    //修改属性
    public function modify()
    {
        $uid = Request::param('uid/d', 0);
        $id = Request::param('id/d', 0);
        $param['name'] = Request::param('name/s', '');
        $logParam['uid'] = $uid;
        $param['partner_id'] = get_partner_id($uid);
        $logParam['ip'] = Request::ip();
        $data = WmsWarehouseAttrService::edit($param, $logParam, $id);
        if ($data == 10000) {
            returnSuccess(200, '修改成功');
        } else {
            returnFail(21101, '修改失败');
        }
    }

    //删除属性
    public function del()
    {
        $uid = Request::param('uid/d', 0);
        $logParam['uid'] = $uid;
        $param['partner_id'] = get_partner_id($uid);
        $id = Request::param('id/d', 0);
        $logParam['ip'] = Request::ip();
        $data = WmsWarehouseAttrService::del($param, $logParam, $id);
        if ($data == 10000) {
            returnSuccess(200, '删除成功', $data);
        } else {
            returnFail(21101, '删除失败');
        }
    }
}
